package com.spring.sunflower.dialog

import android.content.Context
import android.content.Intent
import android.os.Handler
import android.text.TextUtils
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.Nullable
import com.bumptech.glide.Glide
import com.lxj.xpopup.core.PositionPopupView
import com.makeramen.roundedimageview.RoundedImageView
import com.spring.sunflower.R
import com.spring.sunflower.util.SPUtils

/**
 * Created by Kevin on 2021/11/17<br/>
 *
 * Describe:<br/>
 */
class CustomerDialog(context: Context) : PositionPopupView(context) {
    private var tvDone: TextView? = null
    private var close: ImageView? = null
    private var titleCustomer:TextView? = null;
    val r = Runnable { if (isShow) dismiss() }
    private val mHandler by lazy { Handler() }
    override fun getImplLayoutId(): Int {
        return R.layout.dialog_customer
    }

    override fun onCreate() {
        super.onCreate()

        tvDone = findViewById(R.id.tvDone)
        close = findViewById(R.id.ivClose)
        titleCustomer = findViewById(R.id.title_customer);

        tvDone?.setOnClickListener {
            listener?.onFollowedClick()
            dismiss()
        }
        close?.setOnClickListener {
            listener?.onFollowedCloseClick()
            dismiss()
        }
        titleCustomer?.setText(SPUtils.getStringSP("customerImTips",context))
        mHandler.postDelayed(r, 5000)
    }

    override fun onDismiss() {
        super.onDismiss()
        mHandler.removeCallbacks(r)
    }

    private var listener: OnCustomerListener? = null
    fun setOnCustomerListener(l: OnCustomerListener?) {
        listener = l
    }

    interface OnCustomerListener {
        fun onFollowedClick()
        fun onFollowedCloseClick()
    }

}